﻿using System;
using Csla;
using BizControl.DalLinq;

namespace BizControl.Library.BusinessObjects.Categories
{
  [Serializable()]
  public class CategoryInfo : ReadOnlyBase<CategoryInfo>, ISupportEmptyValue
  {
    public Guid Id { get; private set; }
    public string Name { get; private set; }

    public override string ToString()
    {
      return Name;
    }

    private CategoryInfo()
    { /* require use of factory methods */ }

    internal CategoryInfo(Guid id, string name)
    {
      Id = id;
      Name = name;
    }

    public CategoryInfo(Category category)
    {
      if (category != null)
      {
        Id = category.CategoryId;
        Name = category.Name;
      }
    }

    public override bool Equals(object obj)
    {
      if (obj is CategoryInfo)
        return Id == (obj as CategoryInfo).Id;
      return false;
    }

    public override int GetHashCode()
    {
      return base.GetHashCode();
    }

    #region ISupportEmtpyValue Members

    public bool IsEmpty()
    {
      return Id == Guid.Empty;
    }

    #endregion
  }
}
